package com.jhc.drone.communication.enums;

import com.jhc.drone.communication.ws.WsDto;
import com.jhc.drone.communication.ws.WsEndpoint;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @author lcp
 * @describe 描述：无人机飞行模式 枚举
 */
@Slf4j
@Getter
public enum FlyModeEnum {
    MANUAL_MODE(1L, "手动模式"),
    STUNT_MODE(2L, "特技模式"),
    SELF_STAB_MODE(3L, "自稳模式"),
    HEIGHT_HOLD_MODE(4L, "定高模式"),
    POINT_HOLD_MODE(5L, "定点模式"),
    ONE_CLICK_TAKEOFF(11L, "一键起飞"),
    ONE_CLICK_LAND(12L, "一键降落"),
    HOVER_MODE(13L, "悬停模式"),
    SPIRAL_MODE(14L, "盘旋模式"),
    TASK_MODE(15L, "任务模式"),
    RETURN_MODE(16L, "一键返航"),
    FOLLOW_MODE(17L, "自动跟随"),
    POINTING_FLIGHT(18L, "指点飞行"),
    EXTERNAL_INSTRUCTIONS(19L, "外部指令"),
    LOITERING_MUNITIONS_MODE(20L, "巡飞弹模式"),
    POD_FOLLOW_FLIGHT(21L, "吊舱跟飞"),
    POD_GUIDANCE(22L, "吊舱导引"),
    RESERVED_MODE(23L, "预留模式"),
    FIXED_POINT_HOVER_CIRCLING_INCLUDED(101L, "定点悬停/盘旋包含"),
    EMERGENCY_RETURN_PROTECTION(102L, "应急返航保护"),
    FIXED_POINT_LAND_PROTECTION(103L, "定点降落保护"),
    EMERGENCY_LAND_PROTECTION(104L, "紧急迫降保护d"),
    CONSTANT_SPEED_PARALLEL_PROTECTION(105L, "定速平行保护"),
    EMERGENCY_STOP_PROTECTION(106L, "急停保护"),
    FORCED_TERMINATION(107L, "强制终止");

    private final Long code;

    private final String name;

    FlyModeEnum(Long code, String name) {
        this.code = code;
        this.name = name;
    }

    public static FlyModeEnum getModel(Long code) {
        return Stream.of(FlyModeEnum.values()).filter(a -> Objects.equals(a.getCode(), code)).findFirst().orElse(null);
    }
}
